<template>
  <div class="common-title flex">
    <div class="title f1 flex align-center">
      <div class="count">{{ count }}</div>
      {{ title }}

      <div v-if="isShowBtn" class="flex">
        <div class="click-btn margin" :class="{ 'click-active': isClick }" @click="handelClickWeek">最近七天</div>
        <div class="click-btn" :class="{ 'click-active': !isClick }" @click="handelClickMounth">最近30天</div>
      </div>
    </div>
    <div class="unit flex column">
      <div v-if="unit">[单位:{{ unit }}]</div>
    </div>
  </div>
</template>

<script>
export default {
  name: '',
  props: {
    // 'count', 'title', 'unit'
    count: [String, Number],
    title: [String, Number],
    unit: [String, Number],
    isShowBtn: {
      type: Boolean,
      default: false,
    },
  },
  data() {
    return {
      isClick: true,
    }
  },
  methods: {
    handelClickWeek() {
      this.isClick = !this.isClick
      this.$emit('clickWeek')
    },
    handelClickMounth() {
      this.isClick = !this.isClick
      this.$emit('clickMounth')
    },
  },
}
</script>

<style scoped lang="less">
.common-title {
  width: 3.8rem;
  height: 0.36rem;
  background: url('~@/assets/imgs/dashboard/common_title_bg.png') no-repeat center / 100% 100%;

  font-size: 0.14rem;
  font-weight: 800;
  color: #a3d1ff;
  .count {
    width: 0.28rem;
    height: 0.24rem;
    line-height: 0.24rem;
    text-align: center;
    border: 1px solid #1388ff;
    background: linear-gradient(to top, #0170dd, #018ce5, #019deb, #00b2f2);
    margin: 0 0.1rem;

    font-size: 0.16rem;
    font-family: DIN;
    font-weight: 500;
    color: #a3d1ff;
  }

  .unit {
    font-size: 0.12rem;
    font-weight: 400;
    // color: #1388ff;
    color: #fff;
    justify-content: flex-end;
    padding: 0 0.05rem 0.02rem 0;
  }

  .margin {
    margin: 0 0.1rem;
  }

  .click-btn {
    cursor: pointer;
    padding: 0 0.1rem;
    // width: 0.8rem;
    height: 0.22rem;
    line-height: 0.22rem;
    text-align: center;
    background: #125cc3;
    border: 1px solid #0869de;
    color: #0090ff;
    border-radius: 0.1rem;
    font-size: 0.14rem;
    font-weight: 500;
  }

  .click-active {
    background: #006fe0;
    border: 1px solid #0b84ff;
    color: #01d8ff;
    font-weight: bold;
  }
}
</style>
